﻿#pragma once

#include "RBTree.h"

namespace tianci
{
	template<class K, class V>
	class map
	{
		struct MapKeyOfT
		{
			const K& operator()(const pair<K, V>& kv)
			{
				return kv.first;
			}
		};

	public:
		typedef typename RBTree<K, pair<const K, V>, MapKeyOfT>::Iterator iterator;
		typedef typename RBTree<K, pair<const K, V>, MapKeyOfT>::ConstIterator const_iterator;

		iterator begin()
		{
			return _rbtree.Begin();
		}

		iterator end()
		{
			return _rbtree.End();
		}

		const_iterator begin()const
		{
			return _rbtree.Begin();
		}

		const_iterator end()const
		{
			return _rbtree.End();
		}

		pair<iterator, bool> insert(const pair<K, V>& kv)
		{
			return _rbtree.Insert(kv);
		}

	private:
		RBTree<K, pair<const K, V>, MapKeyOfT> _rbtree;
	};
}
